package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/8/5 10:23
 * @apiNote
 */

public class Test00551CheckRecord {
    public boolean checkRecord(String s) {
        int countA = 0, countL = 0;
        int preL = -1;
        for(int i = 0;i<s.length();i++){
            if(s.charAt(i) == 'A'){
                countA++;
                if(countA > 1){
                    return false;
                }
            }
            if(s.charAt(i) == 'L'){
                if(preL != i-1){
                    countL=0;
                }
                preL = i;
                countL++;
                if(countL > 2){
                    return false;
                }
            }
        }
        return true;
    }
}
